Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.IO

Partial Class EditContent
    Inherits System.Web.UI.Page

    Private _dbConnection As IDataStore
    Private _contentKey As String
    Private _pageName As String

    Protected Sub Page_Load(ByVal sender As Object, _
            ByVal e As System.EventArgs) Handles Me.Load

        _contentKey = Request.QueryString("contentkey")
        _pageName = Request.QueryString("page")
        _dbConnection = New XmlManipulator(_pageName)
        _dbConnection.ContentKey = _contentKey

    End Sub

    Protected Sub Page_PreRender(ByVal sender As Object, _
            ByVal e As System.EventArgs) Handles Me.PreRender

        'Load our editor with the staged content.
        txtEditor.Text = _dbConnection.GetContent(1)

    End Sub

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        _dbConnection.SaveContent(txtEditor.Text)
        pnlCloseWindowJs.Visible = True
    End Sub

    'This shouldn't fire, it should do it client side.
    Protected Sub lnkCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkCancel.Click
        pnlCloseWindowJs.Visible = True
    End Sub

End Class
